<?php

namespace App\Events;

use App\Constants\HandleTypeConstant;
use App\Helpers\Utils;
use App\Models\Orm\Platform;
use Illuminate\Broadcasting\Channel;
use Illuminate\Queue\SerializesModels;
use Illuminate\Broadcasting\PrivateChannel;
use Illuminate\Broadcasting\PresenceChannel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class ProductActionEvent
{
    use InteractsWithSockets, SerializesModels;

    /**
     * Create a new event instance.
     *
     * @return void
     */

    public $post;

    public function __construct($post)
    {

        $this ->create_time = date("Y-m-d H:i:s",time());
        $this -> create_ip  = Utils::ipAddress();
        $this -> type  = $post['type'];//1.审核2.添加3.修改
        $this -> handler = auth('admin')->user()->name;
        $this -> handler_id = auth('admin')->user()->id;
        $this -> admin_users_id = $post['admin_users_id'];
        $this ->id = $post['id'];
        if($post['type']==1){
            $this -> handle_content = $post['handle_content']."---审核";

        }elseif($post['type']==2){

            $this -> handle_content = $post['handle_content']."---添加产品";

        }elseif($post['type']==3){
            $this -> handle_content = $post['handle_content']."---修改产品";

        }



    }

    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        return new PrivateChannel('channel-name');
    }
}
